import java.util.Arrays;

public class Exercise2 {
    public int majorityElement(int[] nums) {
        //方法1
        int n = nums.length;
        if(n == 1) {
            return nums[0];
        }
        Arrays.sort(nums);
        return nums[n/2];
    }
}
